<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script>
var entry_id = '{{.entry_id}}';
var products_id = '{{.products_id}}';
var middle_id = '{{.middle_id}}';
var dataTables1 = $('#dataTables-1').DataTable({
    order:[]
    ,columns: [
        {"bSortable": false, render:function(data, type, full, meta) {
                return '<div align="left" style="padding-left:3px"><input type="checkbox" class="selectOne-1" data-id="'+ full.Id +'" value="'+ meta.row +'"></div>';
        }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Products.Name;
        }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.sph;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.cyl;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.add;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.ModelNumber;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.ColourNumber;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Size;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.FunctionInfo;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.FilmColor;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Genre;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Products.Spec;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Acceptance.lot_number;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Acceptance.manufacture_date > 0 ? timetransDate(full.Acceptance.manufacture_date) : '';
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Acceptance.expiry_date > 0 ? timetransDate(full.Acceptance.expiry_date) : '';
        }}
        ,{"data" : "purchase_num","bSortable": false, render:function(data, type, full, meta) {
                return data;
        }}
    ]
    ,"serverSide": false
    ,"bPaginate" : false
    ,"bFilter" : false	//是否启动过滤、搜索功能
    ,"bInfo" : false //是否显示页脚信息，DataTables插件左下角显示记录数
    ,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示
    ,"drawCallback": function(settings){
    }
});

//获取中间表信息
function getMiddleData() {
    if(middle_id == '0') {
        return false;
    }
    var dt = $('#dataTables-1').DataTable();
    $.post('{{  urlfor "EntryreturnController.GetMiddleDataForEntry"}}', {'middle_id':Number(middle_id)}, function(res){
         if(res.code == 0) {
             $.each(res.data, function(index, value){
                 dt.row.add(value).draw();
             });
         }
    }, 'json');

}
getMiddleData();

</script>